import * as multer from 'multer'
import { mkdirSync } from 'fs'
import { join } from 'path'
import * as process from "process";

const storage = multer.diskStorage({
    destination(req,file, callback) {
        try {
            mkdirSync(join(process.cwd(), '/my-uploads'))
        } catch (e) {}
        callback(null, join(process.cwd(), '/my-uploads'))
    },
    filename(req, file, cb) {
        const filename = Buffer.from(file.originalname, "latin1").toString(
            "utf8"
        );
        cb(null, filename)
    }
})

export { storage }
